﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyNganHangDe.GUI.DuLieu
{
    public partial class FormProgress : Form
    {
        public event DoWorkEventHandler DoWork;
        public event RunWorkerCompletedEventHandler RunWorkerCompleted;

        public FormProgress()
        {
            InitializeComponent();
            worker.WorkerSupportsCancellation = false;
            worker.WorkerReportsProgress = false;
            worker.DoWork += worker_DoWork;
            worker.RunWorkerCompleted += worker_RunWorkerCompleted;	
        }

        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (this.RunWorkerCompleted != null)
                {
                    this.Close();
                    RunWorkerCompleted(sender, e);
                }
            }
            catch
            {
            }
        }

        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (this.DoWork != null)
                DoWork(sender, e);
        }

        public void StartWorking(Form frmParent)
        {
            worker.RunWorkerAsync();
            this.ShowDialog(frmParent);
        }
    }
}
